﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.ErrorCode;

namespace Traceability.APP.Controllers
{/// <summary>
 /// 上传图片
 /// </summary>
 /// <param name="file"></param>
 /// <returns></returns>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UpFailController : ControllerBase
    {
        /// <summary>
        /// 上传图片
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Upload(IFormFile file)
        {
            var path = Directory.GetCurrentDirectory() + "/wwwroot/Files/" + file.FileName;
            using (FileStream fs = new FileStream(path, FileMode.Create))
            {
                file.CopyTo(fs);
                fs.Flush();
            }
            return Ok("http://localhost:5050/Files/" + file.FileName);
        }
    }
}
